package com.lv.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lv.xulin.demopro.R;

import java.util.List;

/**
 * Created by xulin on 2017/5/23.
 * xulin67@163.com
 */

public class RvAdapter extends RecyclerView.Adapter<RvAdapter.MyHolder> {
    private Context context;
    private List<String> mDatas;
    public RvAdapter(Context context, List<String> mDatas){
        this.context=context;
        this.mDatas = mDatas;
    }

    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType)
    {
        MyHolder holder = new MyHolder(LayoutInflater.from(
                context).inflate(R.layout.item_ding_rvshow, parent,
                false));
        return holder;
    }

    @Override
    public void onBindViewHolder(MyHolder holder, int position)
    {
        holder.tv.setText(mDatas.get(position));
    }

    @Override
    public int getItemCount()
    {
        return mDatas.size();
    }

    class MyHolder extends RecyclerView.ViewHolder {
        TextView tv;
        public MyHolder(View itemView) {
            super(itemView);
            tv = (TextView) itemView.findViewById(R.id.id_num);
        }
    }
}
